import { ref } from 'vue'
import { defineStore } from 'pinia'
import axios from 'axios'

export const useUserStore = defineStore('counter', () => {
  const user = ref(null)
  const setInfo = (info) => {
    user.value = info
  }

  const getInfo = () => {
    axios
      .get('http://localhost:3000/api/get')
      .then((res) => {
        console.log(res)
        user.value = res.data
        console.log(user.value)
      })
      .catch((err) => {
        console.log(err)
      })
  }

  return { user, setInfo, getInfo }
})

export default useUserStore
